<template>
  <div class="article-tag">
    <div class="word-category">
      分类:
      <nuxt-link to>{{wordTags.category.name}}</nuxt-link>
    </div>
    <div class="word-category">标签:</div>

    <template v-if="formatTags.length">
      <el-tag v-for="(item,index) of formatTags" type="plain" class="pointer" :key="index">{{item}}</el-tag>
    </template>
    <div v-else class="not-has-tag">暂无标签</div>
  </div>
</template>

<script>
export default {
  props: {
    wordTags: {
      type: Object,
      default() {
        return ''
      }
    }
  },

  computed: {
    formatTags() {
      return this.wordTags.label ? this.wordTags.label.split(',') : []
    }
  }
}
</script>

<style lang="scss" scoped>
.article-tag {
  padding: 10px 20px;
  background-color: #fff;
  border-top: 1px solid #f2f2f2;

  .word-category {
    padding-bottom: 10px;
  }

  .el-tag--plain {
    margin-right: 5px;
    border-radius: 0;
    color: var(--theme);
  }

  &-item {
    --height: 30px;
    padding: 0 10px;
    margin: 0 5px 5px 0;
    height: var(--height);
    line-height: 28px;
    border-radius: var(--height);
    border: 1px solid #ededed;
    user-select: none;
    cursor: pointer;
  }

  .not-has-tag {
    color: #999;
  }
}
</style>